/*
 * @Description: vuex仓库
 * @Version: 2.0
 * @Autor: lhl
 * @Date: 2021-06-09 21:42:24
 * @LastEditors: lhl
 * @LastEditTime: 2021-06-20 20:53:19
 */
import { createStore } from 'vuex'
import VuexPersistence from 'vuex-persist'
import tags from './modules/tag' // 普通模式导入每个模块
import language from './modules/language' // 普通模式导入每个模块

const vuexLocal: any = new VuexPersistence({
  storage: window.localStorage
})
const store = createStore({
  state: {
    langPicker: false,
    collapse: true,
    menuList: [] // 菜单数据
  },
  mutations: {
    showLangPicker(state) {
      state.langPicker = true
    },
    hideLangPicker(state) {
      state.langPicker = false
    },
    // 侧边栏折叠
    handleCollapse(state, collapseStatus): void {
      state.collapse = collapseStatus
    },
    setMenu(state, list: any) {
      state.menuList = list
    }
  },
  getters: {
    langPicker: state => state.langPicker,
    collapse: state => state.collapse,
    menuList: state => state.menuList
  },
  actions: {},
  modules: {
    tags,
    language
  },
  plugins: [vuexLocal.plugin]
})
export default store
